#include <iostream>
#include <mysql/mysql.h>
#include <string>

const std::string host = "127.0.0.1";
const std::string user = "root";
const std::string passwd = "1234560";
const std::string db = "test";
const unsigned int port = 3306;


int main()
{
    MYSQL * my = mysql_init(nullptr);
     if(nullptr == my)
    {
        std::cerr <<"init MySQL error"<<std::endl;
        return 1;
    }
    if(mysql_real_connect(my,host.c_str(),user.c_str(),passwd.c_str(),db.c_str(),port,nullptr,0)==nullptr)
    {
        std::cerr <<"connect MySQL error"<<std::endl;
        return 2;
    }
    std::cout<<"connect MySQL success"<<std::endl;
    return 0;
}
